package com.exigen.perflabstat.tables.models;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.exigen.perflabstat.models.ProjectName;

public class ProjectNameModel extends ListDataModel<ProjectName> implements SelectableDataModel<ProjectName> {  

    public ProjectNameModel() {
    }

    public ProjectNameModel(List<ProjectName> data) {
        super(data);
    }
    
    @SuppressWarnings("unchecked")
	public ProjectName getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<ProjectName> projects = (List<ProjectName>) getWrappedData();
        
        for(ProjectName project : projects) {
            if(project.getPROJECT_NAME().equals(rowKey))
                return project;
        }
        
        return null;
    }

    public Object getRowKey(ProjectName project) {
        return project.getPROJECT_NAME();
    }
}
                    